home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Modules / NON-AMIGA / dump.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-03  |  1.6 KB  |  69 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. typedef struct {
  5.     const unsigned char category;   /* index into
  6.                        _PyUnicode_CategoryNames */
  7.     const unsigned char combining;  /* combining class value 0 - 255 */
  8.     const unsigned char bidirectional;  /* index into
  9.                        _PyUnicode_BidirectionalNames */
  10.     const unsigned char mirrored;   /* true if mirrored in bidir mode */
  11.     const char *decomposition;      /* pointer to the decomposition
  12.                        string or NULL */
  13. } _PyUnicode_DatabaseRecord;
  14.  
  15.  
  16. extern const _PyUnicode_DatabaseRecord *_PyUnicode_Database[16];
  17.  
  18.  
  19. static char stringtable[200000];
  20. static char *stringOffset = stringtable;
  21.  
  22. static void DumpBlock(FILE* fh, const _PyUnicode_DatabaseRecord * block)
  23. {
  24.     int i;
  25.     static int recordNum = 0;
  26.  
  27.     for(i=0; i< 4096; i++)
  28.     {
  29.         _PyUnicode_DatabaseRecord copy = block[i];
  30.         if(copy.decomposition)
  31.         {
  32.             strcpy(stringOffset, copy.decomposition);
  33.             copy.decomposition = (const char*)(stringOffset - stringtable);
  34.             stringOffset += strlen(stringOffset)+1;
  35.         }
  36.         fwrite(©, sizeof(_PyUnicode_DatabaseRecord), 1, fh);
  37.         recordNum++;
  38.     }
  39. }
  40.  
  41. int main(void)
  42. {
  43.     int i;
  44.     FILE *fh;
  45.     unsigned int blocklen = 4096 * sizeof(_PyUnicode_DatabaseRecord);
  46.  
  47.     /* write 16 data blocks: */
  48.     puts("Writing data blocks");
  49.     fh=fopen("Unicode_DB.data","wb");
  50.     for(i=0; i<16; i++)
  51.     {
  52.         unsigned long crc;
  53.         char filename[200];
  54.  
  55.         DumpBlock(fh, _PyUnicode_Database[i]);
  56.     }
  57.     fclose(fh);
  58.  
  59.     /* write strings */
  60.     puts("Writing string table");
  61.     blocklen = stringOffset - stringtable;
  62.     printf("Stringtable = %d\n", blocklen);
  63.     fh=fopen("Unicode_DB.strings","wb");
  64.     fwrite(stringtable, blocklen, 1, fh);
  65.     fclose(fh);
  66.  
  67.     return 0;
  68. }
  69.